package ${package}.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import ${package}.service.${table.className}Service;
import ${package}.entity.${table.className};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
public class ${table.className}Controller {

     @Autowired
     private ${table.className}Service ${lowerClassName}Service;

     @RequestMapping(value = "/${path}",method = RequestMethod.GET)
     public ${table.className} get${table.className}ById(@RequestParam("id") Long id){
        return ${lowerClassName}Service.get${table.className}ById(id);
     }

     @RequestMapping(value = "/${paths}",method = RequestMethod.GET)
     public List<${table.className}> get${table.className}ListByMap(@RequestParam Map<String,Object> param){
        return ${lowerClassName}Service.get${table.className}ListByMap(param);
     }

     @RequestMapping(value = "/${paths}/count",method = RequestMethod.GET)
     public Integer get${table.className}CountByMap(@RequestParam Map<String,Object> param)throws Exception{
        return ${lowerClassName}Service.get${table.className}CountByMap(param);
     }

     @RequestMapping(value = "/${path}",method = RequestMethod.PUT)
     public Integer add${table.className}(@RequestBody ${table.className} ${lowerClassName}){
        return ${lowerClassName}Service.insert${table.className}(${lowerClassName});
     }

     @RequestMapping(value = "/${path}",method = RequestMethod.POST)
     public Integer update${table.className}(@RequestBody ${table.className} ${lowerClassName}){
        return ${lowerClassName}Service.update${table.className}(${lowerClassName});
     }

    @RequestMapping(value = "/${path}",method = RequestMethod.DELETE)
    public Integer delete${table.className}(@RequestParam("id") Long id){
        return ${lowerClassName}Service.delete${table.className}ById(id);
    }
}
